﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using Skynet.BusinessEntities;
namespace Skynet.BusinessLogic.DataAccess
{
    public class SecurityRuleRepository : MasterRepository<BusinessEntities.SecurityRule>, ISecurityRuleRepository
    {

        public SecurityRuleRepository(IUnityContainer container)
            : base(container)
        { 

        }
        public void MaintenanceRule(BusinessEntities.SecurityRule Item)
        {
            using (var ctx = this.ContainerService.Resolve<BusinessEntities.SkyNetLibraryEntities>())
            {                
                ctx.SecurityRules.ApplyChanges(Item);
                ctx.SaveChanges(); 
            }            
        }
        public SecurityRule GetOne(string ApplicationName, string ActionName)
        {
            var ctx = this.ContainerService.Resolve<BusinessEntities.SkyNetLibraryEntities>();
            var query = (from c in ctx.SecurityRules where c.ApplicationName ==  ApplicationName  && c.ActionName == ActionName select c).FirstOrDefault();
            return query;              
        }


    }
}
